<!--抵押注销登记-->
<template>
  <div class="ehb all">
    <ehb-header :service-name="jdxx.ywlxmc" :area="jdxx.jdmc"></ehb-header>
    <ehb-multi-process :current.sync="current" :steps="steps" :is-submit="isSubmit" @nextClick="nextClick"
                       @complete="complete">
      <div v-if="current==1" v-html="text.workGuide"></div>
      <div v-if="current==2" v-html="text.readingNote"></div>
      <div v-if="current==3">
        <form class="form">
          <div class="formItem">
            <div class="label">办理网点选择<span style="color: red">&nbsp;*</span></div>
            <span class="input" v-bind:class="addBlwdStep.isGray?'isGray':''" @click="getBlwd()"><span
              style="width: 95%;">{{addBlwdStep.blwd.name}}</span><img src="../../assets/img/pulldown.png"></span>
          </div>
        </form>
      </div>
      <div v-if="current==4">
        <form class="form">
          <div class="formItem">
            <span style="font-size: 0.30rem;">证书类型</span>

            <RadioGroup v-model="addInfoStep.zslx">
              <Radio label="1" style="font-size: 0.30rem;">不动产证明号</Radio>
              <Radio label="2" style="font-size: 0.30rem;">旧证书号</Radio>
            </RadioGroup>
          </div>
          <div class="formItem" v-if="addInfoStep.zslx=='1'">
            <div class="divInput">
              <span>鄂(<span style="width: 3.30rem;height: 0.86rem;padding-left: 0.2rem;align-items: center;"
                            @click="getDate()">{{addInfoStep.bdch.date}}<img
                style="width: 0.6rem;height: 0.3rem;transform: rotate(90deg);color: black;"
                src="../../assets/img/arrow.svg"/>)</span></span>
              <ehb-input-clear inputType="text" textName="城市" placeholder="请输入XX市/县" @inputChanged="inputValue($event)"
                               @clearInput="clearInput" @blur="blur()" :current-value.sync="addInfoStep.bdch.city"
                               className="city"></ehb-input-clear>
            </div>
            <div class="divInput">
            <span>不动产证明第</span>
              <ehb-input-clear inputType="text" textName="序号" placeholder="0000001" @inputChanged="inputValue($event)"
                               @clearInput="clearInput" @blur="blur()" :current-value.sync="addInfoStep.bdch.xh"
                               className="city"></ehb-input-clear>
            <span>号</span></div>
          </div>
          <div class="formItem" v-if="addInfoStep.zslx=='2'">
            <ehb-input-clear inputType="text" textName="证号" placeholder="请输入不动产证明号" @inputChanged="inputValue($event)"
                             @clearInput="clearInput" @blur="blur()" :current-value.sync="addInfoStep.bdczmh"
                             className="input"></ehb-input-clear>
          </div>
        </form>
      </div>
      <div v-if="current==5 && addInfoStep.showInfo">
        <div class="normal-box">
          <div class="normal-title"><span class="icon"></span><span class="text">不动产登记信息(单位：平方米)</span></div>
          <div class="normal-content">
            <div class="normal-row"><span class="col1">不动产证明号：</span><span class="col2"></span>{{addInfoStep.bdczmh}}
            </div>
            <div class="normal-row"><span class="col1">不动产证号：</span><span class="col2"></span>{{addInfoStep.info.fwxx.bdcqzh}}
            </div>
            <div class="normal-row"><span class="col1">房屋坐落：</span><span
              class="col2">{{addInfoStep.info.fwxx.fdzl}}</span></div>
            <div class="normal-row"><span class="col1">不动产单元号：</span><span
              class="col2">{{addInfoStep.info.fwxx.bdcdyh}}</span></div>
            <div class="normal-row"><span class="col1">土地使用权面积：</span><span
              class="col2">{{defaultValue(addInfoStep.info.fwxx.dytdmj,1)}}</span></div>
            <div class="normal-row"><span class="col1">独用土地面积：</span><span
              class="col2">{{defaultValue(addInfoStep.info.fwxx.dytdmj,1)}}</span></div>
            <div class="normal-row"><span class="col1">分摊土地面积：</span><span
              class="col2">{{addInfoStep.info.fwxx.fttdmj}}㎡</span></div>
            <div class="normal-row"><span class="col1">房屋权利类型：</span><span
              class="col2">{{addInfoStep.info.fwxx.qllx}}</span></div>
            <div class="normal-row"><span class="col1">使用期限：</span><span
              class="col2">{{defaultValue(addInfoStep.info.fwxx.tdsyqx,2)}}</span></div>
            <div class="normal-row"><span class="col1">起始时间：</span><span
              class="col2">{{defaultValue(addInfoStep.info.fwxx.tdsyqssj,2)}}</span></div>
            <div class="normal-row"><span class="col1">截止时间：</span><span
              class="col2">{{addInfoStep.info.fwxx.tdsyjssj}}</span></div>
            <div class="normal-row"><span class="col1">规划用途：</span><span
              class="col2">{{addInfoStep.info.fwxx.ghyt}}</span></div>
            <div class="normal-row"><span class="col1">房屋建筑面积：</span><span
              class="col2">{{addInfoStep.info.fwxx.jzmj}}㎡</span></div>
            <div class="normal-row"><span class="col1">房屋套内面积：</span><span
              class="col2">{{addInfoStep.info.fwxx.zyjzmj}}㎡</span></div>
            <div class="normal-row"><span class="col1">房屋分摊面积：</span><span
              class="col2">{{addInfoStep.info.fwxx.ftjzmj}}㎡</span></div>
          </div>
        </div>

        <div class="normal-box">
          <div class="normal-title"><span class="icon"></span><span class="text">权利人信息</span></div>
          <div v-for="(qlr,i) in addInfoStep.info.dyqrList">
            <div class="normal-content">
              <div class="normal-row"><span class="col1">姓名：</span><span class="col2">{{plusXing(qlr.qlrmc,0,1)}}</span></div>
              <div class="normal-row"><span class="col1">证件种类：</span><span class="col2">{{GLOBAL.dicHandle.getName(qlr.zjzl,"zjzl")}}</span>
              </div>
              <div class="normal-row"><span class="col1">证件号：</span><span class="col2">{{plusXing(qlr.zjh,4,4)}}</span></div>
              <div class="normal-row"><span class="col1">电话：</span><span class="col2">{{defaultValue(plusXing(qlr.dh,4,4),2)}}</span></div>
            </div>
          </div>

          <div class="normal-title"><span class="icon"></span><span class="text">义务人信息</span></div>
          <div v-for="(ywr,i) in addInfoStep.info.dyrList">
            <div class="normal-content">
              <div class="normal-row"><span class="col1">姓名：</span><span class="col2">{{plusXing(ywr.qlrmc,0,1)}}</span></div>
              <div class="normal-row"><span class="col1">证件种类：</span><span class="col2">{{GLOBAL.dicHandle.getName(ywr.zjzl,"zjzl")}}</span>
              </div>
              <div class="normal-row"><span class="col1">证件号：</span><span class="col2">{{plusXing(ywr.zjh,4,4)}}</span></div>
              <div class="normal-row"><span class="col1">电话：</span><span class="col2">{{defaultValue(plusXing(ywr.dh,3,3),2)}}</span></div>
            </div>
          </div>
        </div>

      </div>
      <div v-if="current==6">
        <form class="form">
          <div class="formItem" v-for="(fjlx,i) in addAttachmentStep.fjlxList">
            <div class="label">{{i+1}}. {{fjlx.fjlx}}<span style="color: red">&nbsp;*</span></div>
            <div class="upload-pad">
              <div v-for="(fjdz,j) in fjlx.fjdzList">
                <img class="uploadFile" v-bind:src="fjdz"
                     @click='deleteFile(fjdz,i,addAttachmentStep.fjlxList[i].fjlx)'><br/>
              </div>
              <span class="uploadBG" @click="getUploadFj(fjlx.fjlx+(fjlx.fjdzList.length+1),fjlx.fjlxid)"></span>
            </div>
          </div>
        </form>
        <span style="display:block;color: gray;font-size: 14px" @click="getFjAddress()">相关附件模板下载地址(点击复制链接)</span>
        <span style="display:block;color: gray;font-size: 14px"
              @click="getFjAddress()">{{fjAddress}}</span>
      </div>
      <div v-if="current==7">
        <form class="form" v-for="(wxInfo,i) in wxStep.wxList">
          <div class="formItem">
            <div class="label">{{wxInfo.wxxx}}</div>
          </div>
          <div class="formItem">
            <RadioGroup v-model="wxInfo.result">
              <Radio label="是"></Radio>
              <Radio label="否"></Radio>
            </RadioGroup>
          </div>
        </form>
      </div>
      <div v-if="current==8">
        <div style="text-align: center;padding: 20% 5%;" v-html="applyResult"></div>
      </div>
    </ehb-multi-process>
    <ehb-footer :provider="jdxx.provider"></ehb-footer>
  </div>
</template>

<script>
    export default {
        name: "Dyzxdj",
        data() {
            return {
                userInfo: {},
                jdxx: {},
                isSubmit: false,
                current: 1,
                steps: ["办事指南", "阅读须知", "办理网点", "填写信息", "确认信息", "添加附件", "询问记录", "提交成功"],
                text: {
                    workGuide: "",
                    readingNote: ""
                },
                djxx: {},
                addInfoStep: {
                    showInfo: false,
                    bdczmh: "",
                    info: {fwxx: {}, dyqrList: [], dyrList: []},
                    hasAddApplyer: false,
                    bdch: {
                        date: "",
                        city: "",
                        xh: ""
                    },
                    zslx: "1"

                },
                addBlwdStep: {
                    blwd: {
                        name: "请选择办理网点",
                        jdid: ""
                    },
                    isGray: true,
                    blwdList: []
                },
                addAttachmentStep: {
                    fjlxList: []
                },
                wxStep: {
                    wxList: []
                },
                applyResult: "",
                sysLog: {
                    id: "",
                    operatetype: "",
                    operateinfo: "",
                    username: "",
                    usercard: "",
                    mobilephone: "",
                    gnid: ""
                },
                fjAddress: "http://wl.ezrerc.com/hlwyy/Dmain.aspx?cxfs=BSZN"
            }
        },
        mounted() {
            let that = this;
            let pastYear = new Date().getFullYear();
            that.addInfoStep.bdch.date = pastYear;
            ehbAppJssdk.user.getUserInfo({
                success: function (res) {
                    that.userInfo = res;

                }
            });
            ehbAppJssdk.operateWindow.getPrePageParams({
                success: function (res) {
                    that.jdxx = JSON.parse(res);
                    if (that.jdxx.currentStep) {
                        that.jumpStep();
                    } else {
                        ehbAppJssdk.network.request({
                            url: that.GLOBAL.urlConfig.getMyApplication[that.GLOBAL.urlType],
                            method: 'post',
                            data: {'zjh': that.userInfo.idCards, 'jdid': that.jdxx.id},
                            headers: {'contentType': 'application/x-www-form-urlencoded'},
                            success: function (res) {
                                if (res && res.status == 0) {
                                    if (res.result && res.result.length > 0) {

                                        let zt = false;
                                        for (let i in res.result) {
                                            let data = res.result[i];
                                            if (data.ywlxdm == "007") {
                                                if (data.qqzt == 1 || data.qqzt == -1) {
                                                    zt = true;
                                                }
                                            }

                                        }

                                        if (zt) {
                                            ehbAppJssdk.notice.confirm({
                                                title: '提示',
                                                message: '你有未办理的完成的业务，是否前往查看办理？',
                                                buttonLabels: ['取消', '继续办理'],
                                                success: function (res) {
                                                    let status = JSON.parse(res);
                                                    if (status.buttonIndex == 1) {

                                                        let params = {};
                                                        let url = absoultPath + "/onlineProcessing/MyApplication";
                                                        Object.assign(params, that.jdxx);
                                                        ehbAppJssdk.operateWindow.open({
                                                            title: '',
                                                            url: url,
                                                            urlType: 'webPage',
                                                            backRefresh: '1',
                                                            reloadForLogin: '1',
                                                            closeCurrentPage: '1',
                                                            disableScrolling: 'disable',
                                                            params: params,
                                                            pageType: '1',
                                                            pageLevel: '2',
                                                        });
                                                    } else {
                                                        that.getWorkGuid();
                                                    }

                                                }
                                            })
                                        }
                                    }
                                }
                            }
                        });
                    }
                }
            });

            this.getWorkGuid();
        },
        methods: {
            /**
             * 跳转到指定步骤!
             */
            jumpStep() {
                let currentStep = this.jdxx.currentStep;
                if (currentStep > 1) {
                    this.getWorkGuid();
                    this.getReadingNote()
                }
                if (currentStep > 2) {
                    this.getApplyInfo();
                }
                if (currentStep > 5) {
                    this.getAttachmentType();
                    this.getFJList();
                }
                this.current = currentStep;
            },
            /**
             * 查询申请信息
             */
            getApplyInfo() {
                let that = this;
                this.sendRequest(this.GLOBAL.urlConfig.getApplyInfo[this.GLOBAL.urlType], {
                    "sqbsid": this.jdxx.sqbsid
                }, "未查询到申请信息", function (data) {
                    that.addBlwdStep.blwd.jdid = data.djxx.jdid;
                    that.addBlwdStep.blwd.name = data.djxx.jdmc;
                    that.addBlwdStep.isGray = false;
                    if (that.jdxx.currentStep > 3) {
                        that.addInfoStep.bdczmh = data.djxx.bdczmh;
                        let str = data.djxx.bdczmh;

                        if (str) {
                            that.addInfoStep.bdch.date = str.substring(str.indexOf("鄂(") + 2, 6);
                            that.addInfoStep.bdch.city = str.substring(str.indexOf(")") + 1, str.indexOf("不动产证明第"));
                            that.addInfoStep.bdch.xh = str.substring(str.indexOf("不动产证明第") + 6, str.indexOf("号"));
                        }

                    }
                    if (that.jdxx.currentStep > 4) {
                        that.djxx = data.djxx;
                        that.addInfoStep.info.fwxx = data.djxx;
                        that.addInfoStep.showInfo = true;
                        if (data.qlrList) {
                            for (let i in data.qlrList) {
                                let qlr = data.qlrList[i];
                                if (qlr.qlrxz == 2) {
                                    that.addInfoStep.info.dyqrList.push(qlr);
                                } else if (qlr.qlrxz == 1) {
                                    that.addInfoStep.info.dyrList.push(qlr);
                                }
                            }
                        }
                    }
                });
            },
            /**
             * 根据申请标识id查询附件
             */
            getFJList() {
                let that = this;
                this.sendRequest(this.GLOBAL.urlConfig.getFJListBySqbsid[this.GLOBAL.urlType], {
                    "sqbsid": this.jdxx.sqbsid
                }, "未查询到附件信息", function (data) {
                    let fjlxList = that.addAttachmentStep.fjlxList;
                    if (data && data.length > 0 && fjlxList && fjlxList.length > 0) {
                        for (let j in data) {
                            let fj = data[j];
                            for (let i in fjlxList) {
                                let fjlx = fjlxList[i];
                                if (fjlx.fjlxid == fj.fjlxid) {
                                    let fjdzList = fjlx.fjdzList;
                                    if (!fjdzList) {
                                        fjdzList = [];
                                        fjlx.fjdzList = fjdzList;
                                    }
                                    fjdzList.push(that.GLOBAL.urlConfig.getFj[that.GLOBAL.urlType] + "?fjId=" + fj.id);
                                    that.$set(that.addAttachmentStep.fjlxList, j, that.addAttachmentStep.fjlxList[j]);
                                    break;
                                }
                            }
                        }
                    }
                });
            },

            nextClick() {
                switch (this.current) {
                    case 2:
                        this.getReadingNote();
                        break;
                    case 3:
                        break;
                    case 4:
                        this.checkBlwd();
                        break;
                    case 5:
                        this.getInfoByBdcqzh();
                        break;
                    case 6:
                        this.saveApplyInfo();
                        this.getAttachmentType();
                        break;
                    case 7:
                        this.checkUploadFj();
                        this.getWx();
                        break;
                    case 8:
                        this.submitInfo();
                        break;
                }
            },
            /**
             * 获取办事指南
             */
            getWorkGuid() {
                let that = this;
                this.sendRequest(this.GLOBAL.urlConfig.queryArticle[this.GLOBAL.urlType], {
                    "jdid": this.jdxx.id,
                    "typeCode": "0402",
                    "ywlxbm": "007"
                }, "未查询到办事指南", function (data) {
                    that.text.workGuide = data[0].content;
                })
            },
            /**
             * 获取阅读须知
             */
            getReadingNote() {
                let that = this;
                this.sendRequest(this.GLOBAL.urlConfig.queryArticle[this.GLOBAL.urlType], {
                    "jdid": this.jdxx.id,
                    "typeCode": "0401"
                }, "未查询到阅读须知", function (data) {
                    that.text.readingNote = data[0].content;
                })
            },
            /**
             * 获取办理网点
             */
            getBlwd() {
                let that = this;
                this.sendRequest(this.GLOBAL.urlConfig.getJdByPid[this.GLOBAL.urlType], {
                    "pid": this.jdxx.id
                }, "未查询到办理网点", function (data) {
                    if (data && data.length > 0) {
                        that.addBlwdStep.blwdList = [];
                        let names = [];
                        for (let i in data) {
                            that.addBlwdStep.blwdList.push(data[i])
                            names.push(data[i].jdmc);
                        }
                        ehbAppJssdk.notice.actionSheet({
                            title: "办理网点",
                            cancelButton: '取消',
                            otherButtons: names,
                            success: function (res) {
                                let resJson = JSON.parse(res);
                                if (resJson.buttonName != "取消") {
                                    that.addBlwdStep.blwd.jdid = that.addBlwdStep.blwdList[resJson.buttonIndex].id;
                                    that.addBlwdStep.blwd.name = resJson.buttonName;
                                    that.addBlwdStep.isGray = false;
                                }
                            }
                        });
                    }
                })
            },
            /**
             * 检查办理网点
             */
            checkBlwd() {
                if (this.isEmptyStr(this.addBlwdStep.blwd.jdid)) {
                    ehbAppJssdk.notice.alert({
                        title: '提示',
                        message: '请先选择办理网点',
                        buttonName: '收到',
                    })
                    this.current = 3;
                }
            },
            /**
             * 根据不动产权证号获取信息
             */
            getInfoByBdcqzh() {
                let that = this;
                if (that.addInfoStep.zslx == '1') {
                    if (this.isEmptyStr(this.addInfoStep.bdch.date)) {
                        ehbAppJssdk.notice.alert({
                            title: '提示',
                            message: '请输入所属年限',
                            buttonName: '收到',
                        })
                        this.current--;
                        return;
                    }
                    if (this.isEmptyStr(this.addInfoStep.bdch.city)) {
                        ehbAppJssdk.notice.alert({
                            title: '提示',
                            message: '请输入所属市县',
                            buttonName: '收到',
                        })
                        this.current--;
                        return;
                    }
                    if (this.isEmptyStr(this.addInfoStep.bdch.xh)) {
                        ehbAppJssdk.notice.alert({
                            title: '提示',
                            message: '请输入不动产证明号',
                            buttonName: '收到',
                        })
                        this.current--;
                        return;
                    }
                    this.addInfoStep.bdczmh = "鄂(" + this.addInfoStep.bdch.date + ")" + this.addInfoStep.bdch.city + "不动产证明第" + this.addInfoStep.bdch.xh + "号";
                }
                if (this.isEmptyStr(this.addInfoStep.bdczmh)) {
                    ehbAppJssdk.notice.alert({
                        title: '提示',
                        message: '请输入不动产证明号',
                        buttonName: '收到',
                    })
                    this.current--;
                    return;
                }
                ehbAppJssdk.notice.showPreloader({text: "正在查询中.."});
                this.sendRequest(this.GLOBAL.urlConfig.queryDyInfo[this.GLOBAL.urlType], {
                    "jdid": this.addBlwdStep.blwd.jdid,
                  /*天门后台字段是 bdczmh ， 其他的为bdcqzh*/
                    "bdcqzh": this.addInfoStep.bdczmh.trim(),
                  "bdczmh": this.addInfoStep.bdczmh.trim()
                }, "未查询到抵押信息", function (data) {
                  // alert(JSON.stringify(data));
                    ehbAppJssdk.notice.hidePreloader();
                    if (!data || !data.fwxx || data.dyqrList.length == 0) {
                        ehbAppJssdk.notice.alert({
                            title: '提示',
                            message: '未查询到该不动产证明号信息，请确认后重新输入',
                            buttonName: '收到',
                        })
                        that.current--;
                        return;
                    }
                    that.addInfoStep.info = data;
                    that.addInfoStep.showInfo = true;
                });
            },
            /**
             *  保存申请信息
             */
            saveApplyInfo() {
                let that = this;
                let qlrList = this.addInfoStep.info.dyqrList;
                let ywrList = this.addInfoStep.info.dyrList;

                let isSaler = false;

                Object.assign(this.djxx, this.addInfoStep.info.fwxx);
                this.djxx.jdid = this.addBlwdStep.blwd.jdid;
                this.djxx.jdmc = this.addBlwdStep.blwd.name;
                this.djxx.bdczmh = this.addInfoStep.bdczmh;
                this.djxx.ywlxdm = "007";
                this.djxx.ywlxmc = this.jdxx.ywlxmc;
                this.djxx.currentStep = this.current;

                if (ywrList) {
                    for (let i in ywrList) {
                        ywrList[i].qlrlx = "1";
                        ywrList[i].qlrxz = "2";
                        if (!isSaler) {
                            if (ywrList[i].zjh == this.userInfo.idCards) {
                                isSaler = true;
                                ywrList[i].applyUser = "1";
                            }
                        }
                    }
                }

                if (qlrList) {
                    for (let i in qlrList) {
                        qlrList[i].qlrlx = "1";
                        qlrList[i].qlrxz = "1";
                        if (!isSaler) {
                            if (qlrList[i].zjh == this.userInfo.idCards) {
                                isSaler = true;
                                qlrList[i].applyUser = "1";
                            }
                        }
                    }
                }

                let qlrLists = [];
                qlrLists = ywrList.concat(qlrList);

                if (!isSaler) {
                    let qlr = {
                        "qlrmc": this.userInfo.names,
                        "zjh": this.userInfo.idCards,
                        "dh": this.userInfo.mobilePhone,
                        "zjzl": "1",
                        "qlrlx": "1",
                        "qlrxz": "0",
                        "applyUser": "1"
                    };
                    qlrLists.push(qlr);

                }
                this.sendRequest(this.GLOBAL.urlConfig.saveApplyInfo[this.GLOBAL.urlType], {
                    "qlrList": JSON.stringify(qlrLists),
                    "djxx": JSON.stringify(this.djxx)
                }, "保存申请信息失败!", function (data) {
                    that.djxx.id = data.id;
                })
            },
            /**
             * 获取证件种类
             */
            getZjzl() {
                let that = this;
                let names = this.addBuyerStep.zjzlNames;
                ehbAppJssdk.notice.actionSheet({
                    title: "证件种类",
                    cancelButton: '取消',
                    otherButtons: names,
                    success: function (res) {
                        let resJson = JSON.parse(res);
                        if (resJson.buttonName != "取消") {
                            that.addBuyerStep.qlr.zjzl = resJson.buttonIndex + 1;
                        }
                    }
                });
            },
            /**
             * 获取附件类型
             */
            getAttachmentType() {
                let that = this;
                this.sendRequest(this.GLOBAL.urlConfig.getFJLX[this.GLOBAL.urlType], {
                    "jdid": this.jdxx.id,
                    "ywlxbm": "007"
                }, "未查询到附件类型", function (data) {
                    that.addAttachmentStep.fjlxList = data;
                    if (that.addAttachmentStep.fjlxList) {
                        for (let i in that.addAttachmentStep.fjlxList) {
                            that.addAttachmentStep.fjlxList[i].fjdzList = [];
                        }
                    }
                });
            },
            /**
             *  上传附件
             */
            uploadAttachment(fileName, fjlxid) {
                let that = this;
                let sqbsid = this.djxx.id;

                ehbAppJssdk.media.photoAlbum({
                    url: this.GLOBAL.urlConfig.uploadFile[this.GLOBAL.urlType],
                    clipPicture: '2',
                    sqbsid: sqbsid,
                    fileName: fileName,
                    fjlxid: fjlxid,
                    success: function (res) {
                        let resJO = JSON.parse(res);
                        if (resJO.status == 0) {
                            let fjlxList = that.addAttachmentStep.fjlxList;
                            if (fjlxList) {
                                for (let i in fjlxList) {
                                    let fjlx = fjlxList[i];
                                    if (fjlx.fjlxid == fjlxid) {
                                        let fjdzList = fjlx.fjdzList;
                                        if (!fjdzList) {
                                            fjdzList = [];
                                            fjlx.fjdzList = fjdzList;
                                        }
                                        fjdzList.push(that.GLOBAL.urlConfig.getFj[that.GLOBAL.urlType] + "?fjId=" + resJO.result);
                                        that.$set(that.addAttachmentStep.fjlxList, i, that.addAttachmentStep.fjlxList[i]);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                })
            },
            /**
             *  上传拍照附件
             */
            uploadPhotoAttachment(fileName, fjlxid) {

                let that = this;
                let sqbsid = this.djxx.id;
                ehbAppJssdk.media.takePhoto({
                    url: this.GLOBAL.urlConfig.uploadFile[this.GLOBAL.urlType],
                    cameraType: 'cameraRear',
                    clipPicture: '2',
                    sqbsid: sqbsid,
                    fileName: fileName,
                    fjlxid: fjlxid,
                    success: function (res) {

                        let resJO = JSON.parse(res);
                        if (resJO.status == 0) {
                            let fjlxList = that.addAttachmentStep.fjlxList;
                            if (fjlxList) {
                                for (let i in fjlxList) {
                                    let fjlx = fjlxList[i];
                                    if (fjlx.fjlxid == fjlxid) {
                                        let fjdzList = fjlx.fjdzList;
                                        if (!fjdzList) {
                                            fjdzList = [];
                                            fjlx.fjdzList = fjdzList;
                                        }
                                        fjdzList.push(that.GLOBAL.urlConfig.getFj[that.GLOBAL.urlType] + "?fjId=" + resJO.result);
                                        that.$set(that.addAttachmentStep.fjlxList, i, that.addAttachmentStep.fjlxList[i]);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                })
            },
            /**
             * 获取上传附件方式
             */
            getUploadFj(fileName, fjlxid) {

                let that = this;

                ehbAppJssdk.notice.actionSheet({
                    title: "上传附件方式",
                    cancelButton: '取消',
                    otherButtons: ["从本地相册选择", "拍一张照片"],
                    success: function (res) {
                        let resJson = JSON.parse(res);
                        if (resJson.buttonIndex == 0) {
                            that.uploadAttachment(fileName, fjlxid);
                        }
                        if (resJson.buttonIndex == 1) {
                            that.uploadPhotoAttachment(fileName, fjlxid);
                        }

                    }
                });
            },
            /**
             * 检查上传附件
             */
            checkUploadFj() {
                let check = true;
                if (this.addAttachmentStep.fjlxList) {

                    for (let i in this.addAttachmentStep.fjlxList) {
                        let fjdz = this.addAttachmentStep.fjlxList[i].fjdzList;
                        if (fjdz.length > 0) {

                        } else {
                            check = false;
                            break;
                        }
                    }
                }

                if (!check) {
                    ehbAppJssdk.notice.alert({
                        title: '提示',
                        message: '请先上传附件',
                        buttonName: '收到',
                    })
                    this.current = 6;
                    return;
                }

            },
            /**
             *  添加问询
             */
            getWx() {
                let that = this;
                this.sendRequest(this.GLOBAL.urlConfig.getWx[this.GLOBAL.urlType], {
                    "jdId": this.jdxx.id,
                }, "无查询问询信息", function (data) {
                    that.wxStep.wxList = data;
                    if (that.wxStep.wxList != null) {
                        for (let i in that.wxStep.wxList) {
                            that.wxStep.wxList[i].result = "是";
                        }
                    }
                });
            },
            /**
             *  提交信息
             */
            submitInfo() {
                let that = this;
                let pass = true;
                if (this.wxStep.wxList) {
                    for (let i in this.wxStep.wxList) {
                        let wxInfo = this.wxStep.wxList[i];
                        if (wxInfo.result == "否") {
                            pass = false;
                            break;
                        }
                    }
                }
                if (!pass) {
                    ehbAppJssdk.notice.alert({
                        title: '提示',
                        message: '请您先同意问询！',
                        buttonName: '收到',
                    })
                    this.current--;
                    return;
                }
              //天门暂不开放人脸识别功能
              if(this.$globalEnv.enableFaceID){
                //人脸识别，通过才能申请
                ehbAppJssdk.user.AliFaceCompar({
                  name: this.userInfo.names,
                  idCard: this.userInfo.idCards,
                  success:function(res){
                    let data = JSON.parse(res);
                    if(data.resultStatus == "9000"){
                      //提交申请
                      that.isSubmit = true;
                      ehbAppJssdk.notice.showPreloader({text: "正在申请中.."});
                      that.sendRequest(that.GLOBAL.urlConfig.apply[that.GLOBAL.urlType], {
                        "sqbsid": that.djxx.id
                      }, "申请失败!", function (data) {
                        if (data) {
                          that.applyResult = "<p>恭喜您已经申请成功！</p><p>您的申请编号为：" + data + "。</p><p>您的申请已经完成，我们将会在3个工作日内给您答复。</p>";
                        } else {
                          that.steps[that.steps.length - 1] = "提交失败";
                          that.applyResult = "您的申请信息提交失败，请稍后重试！";
                        }
                      })
                    }else {
                      ehbAppJssdk.notice.alert({
                        title: '提示',
                        message: '您没有通过人脸识别认证，请重新提交信息！',
                        buttonName: '收到',
                      });
                      that.current--;
                    }
                  }
                });
              }else {
                //提交申请
                that.isSubmit = true;
                ehbAppJssdk.notice.showPreloader({text: "正在申请中.."});
                that.sendRequest(that.GLOBAL.urlConfig.apply[that.GLOBAL.urlType], {
                  "sqbsid": that.djxx.id
                }, "申请失败!", function (data) {
                  if (data) {
                    that.applyResult = "<p>恭喜您已经申请成功！</p><p>您的申请编号为：" + data + "。</p><p>您的申请已经完成，我们将会在3个工作日内给您答复。</p>";
                  } else {
                    that.steps[that.steps.length - 1] = "提交失败";
                    that.applyResult = "您的申请信息提交失败，请稍后重试！";
                  }
                })
              }
            },
            /**
             *  完成
             */
            complete() {
                ehbAppJssdk.operateWindow.goBack({
                    index: '1'
                })
            },
            deleteFile(url, num, fjlx) {
                let fjId = url.split('fjId=')[1];
                let that = this;
                ehbAppJssdk.notice.contentPopup({
                    title: fjlx,
                    img: url,
                    width: '500',
                    height: '720',
                    buttonName: '删除附件',
                    success: function (res) {
                        let resJson1 = JSON.parse(res);
                        if (resJson1.code == 1) {
                            ehbAppJssdk.notice.confirm({
                                title: '提示',
                                message: '是否确定删除附件照片',
                                buttonLabels: ['取消', '确定'],
                                success: function (res) {
                                    let resJson = JSON.parse(res);
                                    if (resJson.buttonIndex == 1) {
                                        for (let i = 0; i < that.addAttachmentStep.fjlxList.length; i++) {
                                            if (i == num) {
                                                that.addAttachmentStep.fjlxList[i].fjdzList;
                                                for (let j = 0; j < that.addAttachmentStep.fjlxList[i].fjdzList.length; j++) {
                                                    if (url == that.addAttachmentStep.fjlxList[i].fjdzList[j]) {
                                                        that.addAttachmentStep.fjlxList[i].fjdzList.splice(j, 1);
                                                        that.$set(that.addAttachmentStep.fjlxList, i, that.addAttachmentStep.fjlxList[i]);
                                                    }
                                                }
                                            }
                                        }
                                        //调用后台删除附件
                                        // that.sendRequest(that.GLOBAL.urlConfig.deleteFJbyFjId[that.GLOBAL.urlType], {
                                        //     "fjId": fjId
                                        // }, "删除失败", function (data) {
                                        // });
                                    }
                                }
                            });
                        }
                    }
                })
            },
            /**
             * 发送请求
             * @param data
             * @param info
             * @returns {string}
             */
            sendRequest(url, data, info, callback) {
                let that = this;
                ehbAppJssdk.network.request({
                    url: url,
                    method: 'post',
                    data: data,
                    headers: {'contentType': 'application/x-www-form-urlencoded'},
                    success: function (res) {
                        ehbAppJssdk.notice.hidePreloader();
                        if (res.status == 0) {
                            callback(res.result);
                        } else {
                            that.toNOData(info);
                            that.current--;
                        }
                    },
                    fail: function (res) {
                        that.toNOData(info);
                        that.current--;
                        ehbAppJssdk.notice.hidePreloader();
                    }
                });
            },
            blur() {
                document.body.scrollTop = document.documentElement.scrollTop = 0;
            },
            /**
             * 获取当前日期
             */
            getDate() {
                let that = this;
                ehbAppJssdk.notice.datePicker({
                    title: "选择年限",
                    columnsType: '1',
                    minDate: '1900',
                    maxDate: '3029',
                    success: function (res) {
                        let resJson = JSON.parse(res);
                        that.addInfoStep.bdch.date = resJson.year;

                    }
                })
            },
            /**
             * 获取附件地址
             */
            getFjAddress() {
                let txt = this.fjAddress;
                ehbAppJssdk.device.copyText({
                    text: txt,
                })
            }

        }
    }
</script>

<style scoped>
  .normal-box {
    margin-bottom: 0.4rem;
  }

  .normal-title .icon {
    width: 0.1rem;
    height: 0.34rem;
    background: rgba(61, 117, 197, 1);
    display: inline-block;
    vertical-align: middle;
  }

  .normal-title .text {
    width: 6.20rem;
    height: 0.4rem;
    font-size: 0.32rem;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    color: rgba(39, 49, 64, 1);
    line-height: 0.4rem;
    margin-left: 0.2rem;
    display: inline-block;
    vertical-align: middle;
  }

  .normal-content {
    padding: 0.2rem 0;
    border-bottom: #DDDDE0 solid 0.01rem;
  }

  .normal-content .normal-row {
    margin-top: 0.1rem;
    min-height: 0.32rem;
    font-size: 0.26rem;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    color: rgba(165, 173, 185, 1);
    line-height: 0.32rem;
    display: flex;
  }

  .normal-content .normal-row .col1 {
    width: 2.1rem;
    font-family: PingFangSC-Medium;
    font-weight: 500;
    margin-right: 0.3rem;
    flex-shrink: 0;
  }

  .upload-pad {
    display: flex;
    flex-wrap: wrap;
  }

  .upload-pad .uploadFile {
    width: 1.58rem;
    height: 1.58rem;
    margin-right: 0.2rem;
  }

  .upload-pad .uploadBG {
    width: 1.58rem;
    height: 1.58rem;
    background-image: url(../../assets/img/camera.png);
    background-size: 100% 100%;
  }

  .city {
    width: 3.5rem;
    height: 0.86rem;
    background: rgba(249, 249, 251, 1);
    border-radius: 0.04rem;
    border: 0;
    outline: none;
    display: inline-block;
    line-height: 0.5rem;
    padding: 0.18rem 0.3rem;
    display: flex;
    align-items: center;
  }

  .divInput{
    width: 6.30rem;
    height: 0.86rem;
    background: rgba(249, 249, 251, 1);
    border-radius: 0.04rem;
    border: 0;
    padding-left: 0.2rem;
    align-items: center;
  }
</style>
